package com.seckill.enums;

import sun.util.resources.cldr.ti.CalendarData_ti_ER;

/**
 * Desc 使用枚举来表示常量
 * Auth Shinelon
 * Date 2017/7/5
 */
public enum SeckillStateEnum {

    SUCCESS(0,"秒杀成功"),
    END(1,"秒杀结束"),
    REPEAT_KILL(-1,"重复秒杀"),
    INNER_KILL(-2,"系统异常"),
    DATA_REWRITE(-3,"数据被修改");

    private int state;

    private String stateInfo;

    SeckillStateEnum(int state, String stateInfo) {
        this.state = state;
        this.stateInfo = stateInfo;
    }

    public int getState() {
        return state;
    }

    public String getStateInfo() {
        return stateInfo;
    }

    public static SeckillStateEnum stateOf(int index) {
        for (SeckillStateEnum state : values()) {
            if (state.getState() == index) {
                return state;
            }
        }
        return null;
    }
}
